﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master_form.master" AutoEventWireup="true" CodeFile="chom_phongban.aspx.cs" Inherits="App_Form_DanhMuc_chom_phongban" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">

        Ext.require([
        'Ext.selection.CellModel',
        'Ext.grid.*',
        'Ext.data.*',
        'Ext.util.*',
        'Ext.state.*',
        'Ext.form.*',
        'Ext.grid.Panel'
        ]);

        Ext.onReady(function () {

            Ext.QuickTips.init();

            var bd = Ext.getBody();

            var gridForm = Ext.create('Ext.form.Panel',
            {
                id: 'form_phong',
                frame: true,
                layout:
                {
                    type: 'table',
                    columns: 1
                },
                fieldDefaults:
                {
                    labelAlign: 'left',
                    msgTarget: 'side'
                },

                items:
                [
                    {
                        margin: '0 0 5 0',
                        xtype: 'fieldset',
                        title: 'Thông tin tìm kiếm',
                        defaults:
                        {
                            labelWidth: 90
                        },
                        defaultType: 'textfield',
                        items:
                        [
                            {
                                xtype: 'fieldcontainer',
                                combineErrors: true,
                                layout:
                                    {
                                        type: 'hbox',
                                        defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                    },
                                items:
                                [
                                    { xtype: 'displayfield', width: 90, fieldLabel: 'Tên phòng' },
                                    {
                                       xtype:'textfield',
                                        width: 200,
                                        id: 'ten_phong',
                                        name: 'Ten'
                                    },
                                    {
                                        xtype: 'button', width: 50, text: 'Tìm', icon: '',
                                        handler: function () {
                                            var b_ten = Ext.getCmp("ten_phong").value;
                                            DanhMuc.Fs_PHONG_BAN_TIM(b_ten, P_LOAD_TTCHUNG, P_LOI_CSDL, P_LOI_TGIAN);
                                        }
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        xtype: 'gridpanel',
                        margin: '0 0 0 1',
                        store: null,
                        id: 'phongban',
                        width: 400,
                        height: 290,
                        title: 'Danh sách phòng ban',
                        columns: [
                            { id: 'MA1', flex: 1, text: 'Mã', width: 90, sortable: true, hidden: true, dataIndex: 'id_phong' },
                            { id: 'TEN1', text: 'Tên', width: 300, flex: 1, sortable: true, dataIndex: 'Ten' }
                        ],
                        listeners: {
                            selectionchange: function (model, records) {
                                if (records[0]) {                                    
                                    var b_ma = records[0].get("id_phong") + "#" + records[0].get("Ten");
                                    $("#ndung").text(b_ma);
                                }
                            }
                        }
                    }
                ],
                renderTo: bd
            });
            DanhMuc.Fs_PHONG_BAN_LKE(P_LOAD_TTCHUNG, P_LOI_CSDL, P_LOI_TGIAN);
        });

    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="ndung" style="display:none;"></div>
    <script type="text/javascript">
        function P_LOAD_TTCHUNG(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            else {
                var b_chuoi2 = CH_JSON(b_kq);
                var a_data2 = Ext.create('Ext.data.Store', {
                    fields: ['id_phong', 'Ten'],
                    data: b_chuoi2
                });
                var c = Ext.getCmp('phongban');
                c.bindStore(a_data2);
            }
        }
    </script>
</asp:Content>

